<template>
    <div class="qingwu">
        <div class="admin_table_page_title">财务统计</div>
        <div class="unline underm"></div>

        <div class="admin_table_handle_btn">
            <a-form layout="inline" :form="form"  @submit="handleSubmit">

                <a-form-item label="支付状态">
                    <a-select  @change="handleChange" style="width: 120px" v-model="status">
                        <a-select-option  value="" >
                            全部
                        </a-select-option>
                        <a-select-option  value="1" >
                            电费
                        </a-select-option>
                        <a-select-option  value="2" >
                            水费
                        </a-select-option>
                        <a-select-option  value="3" >
                            物业费
                        </a-select-option>
                    </a-select>
                </a-form-item>

                <a-form-item label="创建时间">

                    <a-range-picker v-model="change" @change="onChanged" />
                </a-form-item>

                <a-form-model-item >
                    <a-button icon="search" @click="search">
                        查询
                    </a-button>
                </a-form-model-item>
                <a-form-model-item >
                    <a-button  @click="reset">重置</a-button>
                </a-form-model-item>


                <a-form-item label="总缴费金额: ">

                        <span>{{totals ? totals : ""}}</span>

                </a-form-item>
            </a-form>
        </div>
        <div class="admin_table_list">
            <a-table :columns="columns" :data-source="list" :pagination="false" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" row-key="id">

                <div slot="facilitydata" slot-scope="rows">
                    <p>姓名: {{rows.platform_agent ? rows.platform_agent.agent_name : ""}}</p>
                    <p>手机号: {{rows.platform_agent ? rows.platform_agent.agent_mobile : ""}}</p>
                </div>

                <div slot="orderdata" slot-scope="rows">
                    <p>区域: {{rows.community ? rows.community.name : ''}}</p>
                </div>
                <div slot="userdata" slot-scope="rows">
                    <p>用户: <span> {{rows.username }}</span></p>
                    <p>手机: <span>{{rows.mobile }}</span></p>
                    <p>电费余额: <span> {{rows.electricity_bill_balance }}</span></p>
                    <p>水费余额: <span>{{rows.water_bill_balance }}</span></p>
                    <p>物业费余额: <span> {{rows.property_bill_balance }}</span></p>
                </div>

                <div slot="pay" slot-scope="rows">
                    <p>缴费类型: 电费 缴费金额：{{rows.ele_fee  ? rows.ele_fee : 0}} &nbsp&nbsp&nbsp已扣电费：{{rows.ele_deduction ? rows.ele_deduction : 0}}</p>
                    <p>缴费类型: 水费 缴费金额：{{rows.water_fee ? rows.water_fee : 0}} &nbsp&nbsp&nbsp已扣水费：{{rows.water_deduction ? rows.water_deduction : 0}}</p>
                    <p>缴费类型: 物业费 缴费金额：{{rows.pro_fee ? rows.pro_fee : 0}} &nbsp&nbsp&nbsp已扣物业费 ：{{rows.pro_deduction ? rows.pro_deduction : 0}}</p>
                </div>


            </a-table>
            <div class="admin_pagination" v-if="total>0">
                <a-pagination v-model="params.page" :page-size.sync="params.per_page" :total="total" @change="onChange" show-less-items />
            </div>
        </div>
    </div>
</template>

<script>
export default {
    components: {},
    props: {},
    data() {
      return {
          params:{
              page:1,
              per_page:30,
          },
          total:0, //总页数
          selectedRowKeys:[], // 被选择的行
          columns:[
              {title:'序号',dataIndex:'id',fixed:'left'},
              {title:'代理商',scopedSlots: { customRender: 'facilitydata' }},
              {title:'区域',scopedSlots: { customRender: 'orderdata' }},
              {title:'业主信息',scopedSlots: { customRender: 'userdata' }},
              {title:'支付金额信息', scopedSlots: { customRender: 'pay' }},
          ],
          list:[],
          community_lists: [],
          status:'',
          change:'',
          totals:0

      };
    },
    watch: {},
    computed: {},
    methods: {
        // 选择框被点击
        onSelectChange(selectedRowKeys) {
            this.selectedRowKeys = selectedRowKeys;
        },
        onChanged(date, dateString) {
            this.change = dateString
            // console.log(date, dateString);
        },
        // 状态
        handleChange(value, selectedOptions){
            this.status = value;
        },
        // 选择分页
        onChange(e){
            this.params.page = e;
            this.onload();
        },
        onload(){
            this.$get(this.$api.estateFinanceIndex,this.params).then(res=>{
                this.total = res.data[0].total;
                this.totals = res.data[1];
                this.list = res.data[0].data;
            });
        },
        // 重置
        reset(){
            location.reload();
        },
        // 搜索
        search(){
            this.params['change'] = this.change;
            this.params['status'] = this.status;
            this.$get(this.$api.estateFinanceIndex,this.params).then(res=>{
                this.total = res.data.total;
                this.list = res.data.data;
            });
        },
    },
    created() {
        this.onload();
        // this.getCommunityList();/**/
    },
    mounted() {}
};
</script>
<style lang="scss" scoped>

</style>
